//
//package com.insigma.business.qrcode.common.template;
//
//import com.insigma.business.qrcode.common.util.*;
//import com.insigma.business.qrcode.common.vo.RestfulResult;
//import org.apache.commons.lang3.StringUtils;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.stereotype.Component;
//
//
//@Component
//public class ServiceTemplate {
//
//
//    private static final Logger logger = LoggerFactory.getLogger(ServiceTemplate.class);
//
//
//    public void executeCustom(final RestfulResult restfulResult, final ServiceCallback action) {
//        try {
//
//            action.check();
//
//
//            action.executeService();
//        } catch (AccessFailedException afe) {
//            ExceptionUtil.caught(logger, afe, action.getOperation(), "|执行业务处理失败");
//            setupFailedResult(restfulResult, afe.getErrCode(),afe.getErrMsg(), null);
//        } catch (BizException be) {
//            ExceptionUtil.caught(logger, be, action.getOperation(), "|执行业务处理失败");
//            setupFailedResult(restfulResult, be.getErrorCodeEnum().getCode(),(StringUtils.isNotBlank(be.getMessage())?be.getMessage():be.getErrorCodeEnum().getDesc()), null);
//        } catch (Exception e) {
//            ExceptionUtil.caught(logger, e, action.getOperation(), "|执行业务处理失败");
//            RestfulResultUtil.setupFailed(restfulResult, ConsumerCodeEnum.INTERNAL_ERROR.getCode(), "服务器在偷懒,请迅速举报给客服");
//        }
//    }
//
//
//    private void setupSuccessResult(final RestfulResult restfulResult) {
//        restfulResult.setCode(ConsumerCodeEnum.SUCCESS.getCode());
//        restfulResult.setMsg(ConsumerCodeEnum.SUCCESS.getDesc());
//    }
//
//
//    private void setupFailedResult(final RestfulResult restfulResult,
//                                   final String errorCode, final String errorMsg, final String customErrorMsg) {
//        RestfulResultUtil.setupFailed(restfulResult, errorCode,StringUtils.isBlank(customErrorMsg) ? errorMsg : customErrorMsg);
//
//    }
//}
